<admintpl file="header" />
<link rel="stylesheet" href="__PUBLIC__/css/simple_upload.css" type="text/css" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:U('Admin/LiveCompetitor/index')}">选手列表</a></li>
			<li class="active"><a href="{:U('Admin/LiveCompetitor/add')}">添加选手</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form" enctype="multipart/form-data" action="{:U('Admin/LiveCompetitor/add_post')}">
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;">姓名：</label>
					<div class="span3">
						<input type="text" name="real_name" placeholder="请输入姓名">
					</div>
					<label class="span1 control-label" style="width: 90px;">头像：</label>
					<div class="span4 wrapper">
                          <div id="uploader-image">
                              <div id="fileList" class="uploader-list">
                                  <div id="imageDiv" class="file-item thumbnail" style="width:80px;height: 80px;">
                                      <img id="imagePreview" src="__PUBLIC__/images/furley_bg.png" style="width:80px;height: 70px;">
                                      <div id="picker" class="info">选择图片&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                      <input style="display:none;" type="file" id="imageFile" name="imageFile" >
                                  </div>
                              </div>
                          </div>
                    </div>
				</div>
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;">性别：</label>
					<div class="span3">
						<select name="sex">
							<option value="1">男</option>
							<option value="2">女</option>
						</select>
					</div>
				    <label class="span1 control-label" style="width: 90px;">生日：</label>
					<div class="span3">
						<input type="text" name="birthday" class="js-date"  value="" autocomplete="off">
					</div>
				</div>
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;">绰号：</label>
					<div class="span3">
						<input type="text" name="nickname" placeholder="请输入绰号">
					</div>
					<label class="span1 control-label" style="width: 90px;">籍贯：</label>
					<div class="span3">
						<input type="text" name="native" placeholder="请输入籍贯">
					</div>
				</div>
				
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;">体重：</label>
					<div class="span3">
						<input type="text" name="weight" placeholder="请输入体重">
					</div>
					<label class="span1 control-label" style="width: 90px;">级别：</label>
					<div class="span3">
						<input type="text" name="level" placeholder="请输入级别">
					</div>
				</div>
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;">代表队：</label>
					<div class="span3">
						<input type="text" name="team" placeholder="请输入代表队">
					</div>
					<!--<label class="span1 control-label" style="width: 90px;">人气值：</label>-->
					<!--<div class="span3">-->
						<!--<input type="text" name="popular_value" placeholder="请输入人气值">-->
					<!--</div>-->
				</div>
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;">关键字：</label>
					<div class="span7">
						<input type="text" style="width: 556px;" name="keywords" placeholder="请输入关键字">
					</div>
				</div>
				<div class="control-group">
					<label class="span2 control-label" style="width: 90px;">战绩：</label>
					<div class="span7">
						<textarea style="width: 556px; height: 70px;" name="record"></textarea>
					</div>
				</div>
				<div class="control-group">
					<label class="span2 control-label" style="width: 90px;">介绍：</label>
					<div class="span7">
						<textarea style="width: 556px; height: 70px;" name="introduction"></textarea>
					</div>
				</div>
			<div class="form-actions" style="padding-left:260px;">
				<button type="submit" class="btn btn-primary js-ajax-submit" data-type="add">保存</button>
				&nbsp;&nbsp;<a class="btn" href="{:U('Admin/LiveCompetitor/index')}">{:L('BACK')}</a>
			</div>
		</form>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
	<script type="text/javascript" >
		function add_check(){
			var name = $("input[name='real_name']").val();
			var flag = false;
			$.ajax({
				type:"post",
				async:false,
				url:"{:U('Admin/Movement/filter_words')}",
				data:'name='+name,
				dataType:"text",
				success:function(data){
					if(data){
						if(confirm('您编辑的内容涉及敏感词'+data+'是否继续操作')){
							flag= true;
						}else{
							flag= false;
						}
					}else{
						flag = true;
					}
				}
			});
			return flag;
		}
		function html5Reader(file, previewId){
	        var file = file.files[0];
	        var reader = new FileReader();
	        reader.readAsDataURL(file);
	        reader.onload = function(e){
	            $('#'+previewId).attr('src', this.result);
	        }
	    }
	    function image_change(fileId, previewId) {
	        var pic = document.getElementById(previewId),
	                file = document.getElementById(fileId);
	
	        var ext = file.value.substring(file.value.lastIndexOf(".")+1).toLowerCase();
	
	        // gif在IE浏览器暂时无法显示
	        if(ext != 'png' && ext != 'jpg' && ext != 'jpeg'){
	            alert("图片的格式必须为png或者jpg或者jpeg格式！");
	            return;
	        }
	        var isIE = navigator.userAgent.match(/MSIE/)!= null,
	                isIE6 = navigator.userAgent.match(/MSIE 6.0/)!= null;
	
	        if(isIE) {
	            file.select();
	            var realLocalPath = document.selection.createRange().text;
	
	            // IE6浏览器设置img的src为本地路径可以直接显示图片
	            if (isIE6) {
	                pic.src = realLocalPath;
	            }else {
	                // 非IE6版本的IE由于安全问题直接设置img的src无法显示本地图片，但是可以通过滤镜来实现
	                pic.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image',src=\"" + realLocalPath + "\")";
	                // 设置img的src为base64编码的透明图片 取消显示浏览器默认图片
	                pic.src = '';
	            }
	        }else {
	            html5Reader(file, previewId);
	        }
	    }


		$("#picker").click(function(){
            $("#imageFile").click();
        });
		
		$("#imageFile").change(function(){
			image_change('imageFile', 'imagePreview');
        });
		
	</script>
</body>
</html>